package com.wangnan.springbootstudy;

import com.wangnan.springbootstudy.servlet.MyServlet;
import org.springframework.boot.Banner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
@ServletComponentScan(basePackages = "com.wangnan.springbootstudy.servlet")
public class SpringbootstudyApplication {

    public static void main(String[] args) {
        SpringApplication app = new SpringApplication(SpringbootstudyApplication.class);
        app.setBannerMode(Banner.Mode.OFF);
        app.run();
        System.out.println("aaaaaaaaaaaaaaaaa");
//       SpringApplication.run(SpringbootstudyApplication.class,args);
    }

    //将自定义的servlet添加到springboot容器中，这里指定了urlMappings，则对应的servlet的url会失效
    @Bean
    public ServletRegistrationBean getServletRegistrationBean(){
        MyServlet myServlet = new MyServlet();
        ServletRegistrationBean<MyServlet> bean = new ServletRegistrationBean<>(myServlet,"/svr");
        bean.setLoadOnStartup(1);
        return bean;
    }
}

